﻿unit CSVFile;

interface

uses
  Classes,SysUtils,dialogs,EMMemList,FileInfo;

procedure ExportToCSV(List : TEMMemList;FileName:string);

implementation

procedure ExportToCSV(List : TEMMemList;FileName:string);
var
  CSVFile : TextFile;
  I : Integer;
  EXStr : string;
begin
  AssignFile(CSVFile,FileName);  //关联 文件变量 和 文件的路径 关联
  try
    ReWrite(CSVFile);   //创建或清空已存在的文件，并进行写入
    for I := 0 to List.Count - 1 do
    begin
      ExStr := concat(TFileInfo(List[I]^).FileName,',',
              TFileInfo(List[I]^).FilePath,',',
              TFileInfo(List[I]^).FileType,',',
              concat(floattostr(TFileInfo(List[I]^).FileSize),'KB'),',',
              TFileInfo(List[I]^).FileDate);;
      Writeln(CSVFile,ExStr);
    end;
  finally
    CloseFile(CSVFile);
  end;
end;

end.
